
package com.rt.schedulenew.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;

import java.util.Map;
import java.util.HashMap;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;

import com.rt.schedulebase.dto.DictServersDto;
import com.rt.schedulenew.api.IDictServersService;
import org.springframework.stereotype.Service;
import com.rt.schedulebase.entity.DictServers;
import com.rt.schedulebase.mapper.DictServersMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

@Service
public class DictServersServiceImpl extends ServiceImpl<DictServersMapper, DictServers> implements IDictServersService {
    @Override
    public boolean insertSelective(DictServers dictServers) {
        return retBool(baseMapper.insert(dictServers));
    }

    @Override
    public boolean deleteByPrimaryKey(String key) {
        return retBool(baseMapper.deleteById(key));
    }

    @Override
    public boolean updateByPrimaryKeySelective(DictServers dictServers) {
        return retBool(baseMapper.updateById(dictServers));
    }

    @Override
    public DictServers selectByPrimaryKey(String key) {
        return baseMapper.selectById(key);
    }

    @Override
    public List<DictServers> getList(DictServersDto dto) {
        QueryWrapper<DictServers> qw = new QueryWrapper<>();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("SVR_NAME", dto.getSvrName());
        qw.allEq(map, false);
        List<DictServers> list = baseMapper.selectList(qw);
        return list;
    }

    @Override
    public List<DictServers> getListAll() {
        return baseMapper.selectList(null);
    }

    @Override
    public boolean delete(DictServers dictServers) {
        UpdateWrapper<DictServers> uw = new UpdateWrapper<>();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("SVR_NAME", dictServers.getSvrName());
        uw.allEq(map, false);
        return retBool(baseMapper.delete(uw));
    }

    @Override
    public boolean update(DictServers dictServers) {
        UpdateWrapper<DictServers> uw = new UpdateWrapper<>();
        Map<String, Object> map = new HashMap<>();
        map.put("SVR_NAME", dictServers.getSvrName());
        uw.allEq(map, false);
        return retBool(baseMapper.update(dictServers, uw));
    }

    @Override
    public DictServers getInfo(DictServersDto dto) {
        QueryWrapper<DictServers> qw = new QueryWrapper<>();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("SVR_NAME", dto.getSvrName());
        qw.allEq(map, false);
        return baseMapper.selectOne(qw);
    }
}
